package com.rongcheng.fortestlist.viewPager;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.rongcheng.fortestlist.R;

/**
 * @author frc
 *         created at 16-12-21.
 */

public class FragmentTen extends Fragment {

    @Override
    public void onAttach(Context context) {
        Log.e("frc", "onAttach is true");
        super.onAttach(context);
    }

    private String mArgument;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        Bundle bundle = getArguments();
        if (bundle != null) {
            mArgument = bundle.getString("argument");
        }
        super.onCreate(savedInstanceState);
    }

    public static FragmentTen newInstance(String argument) {
        Bundle bundle = new Bundle();
        bundle.putString("argument", argument);
        FragmentTen fgo = new FragmentTen();
        fgo.setArguments(bundle);
        return fgo;
    }

    TextView tv_test;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.one_fragment, null, false);
        tv_test = (TextView) view.findViewById(R.id.tv_test);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
        if (savedInstanceState != null) {
            String str = savedInstanceState.getString("test_times");
            tv_test.setText("this is test" + times);
        }
        super.onViewStateRestored(savedInstanceState);
    }

    public static int times = 1;

    public boolean IsFragmentLive() {
        return true;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putString("test_times", "" + times++);
        super.onSaveInstanceState(outState);
    }

    @Override
    public boolean getUserVisibleHint() {
        return super.getUserVisibleHint();
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }


    @Override
    public void onStop() {
        super.onStop();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }

    @Override
    public void onDestroy() {
        Log.e("frc", "onDestroy is  true");
        super.onDestroy();
    }

    @Override
    public void onDetach() {
        Log.e("frc", "onDetach is  true");
        super.onDetach();
    }
}
